# Maintainer: Martell Malone < martell malone at g mail dot com >

_realname=go

pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.2
pkgrel=1
pkgdesc="Go Lang"
arch=('any')
groups=("${MINGW_PACKAGE_PREFIX}")
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
url="http://www.golang.org/"

depends=()
options=('!strip')

source=("http://go.googlecode.com/files/go${pkgver}.src.tar.gz"
        "msys2-unix-files.patch")
sha1sums=('7dd2408d40471aeb30a9e0b502c6717b5bf383a5'
          'SKIP')

prepare() {
  cd ${srcdir}/go
  #patch -p1 -i ${srcdir}/msys2-unix-files.patch
}

build() {
  cd ${srcdir}/go/src
  GO_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1" CFLAGS="-D__USE_MINGW_ANSI_STDIO=1" ./make.bat
}

package() {
  mkdir -p ${pkgdir}${MINGW_PREFIX}
  mkdir -p ${pkgdir}${MINGW_PREFIX}/src

  mv "${srcdir}/go/bin" "${pkgdir}${MINGW_PREFIX}/"
  mv "${srcdir}/go/pkg" "${pkgdir}${MINGW_PREFIX}/"

  mv "${srcdir}/go/src/pkg" "${pkgdir}${MINGW_PREFIX}/src/"
  mv "${srcdir}/go/src/cmd" "${pkgdir}${MINGW_PREFIX}/src/"
}
